using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace MageDefender.GameClasses
{
    public class Spell
    {
        public enum Alignments { Damage = 1, Poison = 2, Slow };
        int mana;

        float moveXPosToTarget = 0;

        public float MoveXPosToTarget
        {
            get { return moveXPosToTarget; }
            set { moveXPosToTarget = value; }
        }
        string description;

        public string Description
        {
            get { return description; }
            set { description = value; }
        }

        public int Mana
        {
            get { return mana; }
            set { mana = value; }
        }

        int price;

        public int Price
        {
            get { return price; }
            set { price = value; }
        }


        GameObjects.SpellHandler.Spells type;

        public GameObjects.SpellHandler.Spells Type
        {
            get { return type; }
            set { type = value; }
        }

        int radius;

        public int Radius
        {
            get { return radius; }
            set { radius = value; }
        }

        bool active;

        public bool Active
        {
            get { return active; }
            set { active = value; }
        }

        Matrix viewMatrix;

        public Matrix ViewMatrix
        {
            get { return viewMatrix; }
            set { viewMatrix = value; }
        }

        Vector3 vecEye;

        public Vector3 VecEye
        {
            get { return vecEye; }
            set { vecEye = value; }
        }

        Vector3 position;

        public Vector3 Position
        {
            get { return position; }
            set { position = value; }
        }
        public float PositionX
        {
            get { return position.X; }
            set { position.X = value; }
        }
        public float PositionY
        {
            get { return position.Y; }
            set { position.Y = value; }
        }
        public float PositionZ
        {
            get { return position.Z; }
            set { position.Z = value; }
        }
        Matrix worldMatrix;

        public Matrix WorldMatrix
        {
            get { return worldMatrix; }
            set { worldMatrix = value; }
        }
        string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        int modelID;

        public int ModelID
        {
            get { return modelID; }
            set { modelID = value; }
        }

        float baseDamage;

        public float BaseDamage
        {
            get { return baseDamage; }
            set { baseDamage = value; }
        }
        int minLevel;

        public int MinLevel
        {
            get { return minLevel; }
            set { minLevel = value; }
        }
        float speed;

        public float Speed
        {
            get { return speed; }
            set { speed = value; }
        }
        bool destoryOnHit;

        public bool DestoryOnHit
        {
            get { return destoryOnHit; }
            set { destoryOnHit = value; }
        }

        Vector3 rotation;

        public Vector3 Rotation
        {
            get { return rotation; }
            set { rotation = value; }
        }

        public float RotationX
        {
            get { return rotation.X; }
            set { rotation.X = value; }
        }
        public float RotationY
        {
            get { return rotation.Y; }
            set { rotation.Y = value; }
        }
        public float RotationZ
        {
            get { return rotation.Z; }
            set { rotation.Z = value; }
        }

        Alignments alignment;

        public Alignments Alignment
        {
            get { return alignment; }
            set { alignment = value; }
        }

        Vector3 target;

        public Vector3 Target
        {
            get { return target; }
            set { target = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="t">Spell name</param>
        /// <param name="a">Aligments</param>
        /// <param name="mID">ModelID</param>
        /// <param name="m">Mana req.</param>
        /// <param name="bD">Base damage</param>
        /// <param name="mL">Minimum Level</param>
        /// <param name="s">Speed</param>
        /// <param name="dOH">Is the spell destroyd when hitting something?</param>
        /// <param name="r">radius</param>
        /// <param name="p">position( like players hand )</param>
        /// <param name="price">Price in shop</param>
        /// <param name="desc">SHORT description of the spell</param>
        public Spell(GameObjects.SpellHandler.Spells t, Alignments a, int mID, int m, float bD, int mL, float s, bool dOH, int r, Vector3 p, int price, string desc)
        {
            destoryOnHit = dOH;
            speed = s;
            minLevel = mL;
            baseDamage = bD;
            ModelID = mID;
            position = p;
            active = true;
            radius = r;
            type = t;
            mana = m;
            rotation = new Vector3(0, 0, 0);
            alignment = a;
            name = t.ToString();
            this.price = price;
            description = desc;
            target = Vector3.Zero;
            moveXPosToTarget = 0.0f;
        }

        public void Update(Vector3 v, Matrix vM)
        {
            Matrix objectMatrix = Matrix.CreateRotationX(rotation.X) * Matrix.CreateRotationY(rotation.Y) * Matrix.CreateRotationZ(rotation.Z) * Matrix.CreateTranslation(Position.X, Position.Y, Position.Z);
            Matrix renderMatrix = Matrix.CreateScale(0.0080f);
            worldMatrix = objectMatrix * renderMatrix;
            viewMatrix = vM;

            if (position.Z >= 5500)
            {
                active = false;
            }
        }
    }
}